<?php

$serv = new swoole_websocket_server("0.0.0.0", 9501);

/**
 * 获取请求
 * $serv 服务器对象
 * $request 请求对象  get post header cookie
 * $response 响应对象
 */
$serv->on('request', function ($request, $response) {
    var_dump($request->get);
    $response->header("Content-Type", "text/html;charset=utf-8");  //设置响应头
    $response->cookie("name", "swoole");

    $response->end("<h1>Hello World. #".rand(1000, 9999)."</h1>");
});

// $serv->stat(); //查看状态

$serv->start();  //启动服务器